#ifndef	MVECT_H
#define	MVECT_H

#include <stdint.h>
#include <stdlib.h>

struct	vector {
	uint32_t	vect_cur;
	uint32_t	vect_max;
	uint8_t*	vect_base;
};

#define	INIT_VECTOR(v)					do {		\
	(v)->vect_cur = (v)->vect_max = 0;				\
	(v)->vect_base = NULL;						\
} while (0)

#define	FINI_VECTOR(v)					do {		\
	if ((v)->vect_base != NULL) {					\
		free((v)->vect_base);					\
		INIT_VECTOR(v);						\
	}								\
} while (0)

#define	VECTOR_EMPTY(v)	((v)->vect_cur == 0)
#define	VECTOR_TAIL_OBJ(v, s)	\
	((void*)((v)->vect_base + ((v)->vect_cur - (s))))
#define	VECTOR_POP_OBJ(v, s)	\
	((v)->vect_cur -= s, (void*)((v)->vect_base + (v)->vect_cur))

void*	vector_append_obj(struct vector*, uint32_t);

#endif	/* !MVECT_H */

